n=int(input())
nums=list(map(int,input().split()))

d={}
for x in nums:
    if d.get(x) is None:
        d[x]=1
    else:
        d[x]+=1

ds=[]
for key in d.keys():
    ds.append((key,d[key]))

for i in range(0,len(ds)):
    for j in range(i+1,len(ds)):
        if ds[i][1]<ds[j][1] or (ds[i][1]==ds[j][1] and ds[i][0]>ds[j][0]):
            temp=ds[i]
            ds[i]=ds[j]
            ds[j]=temp

for item in ds:
    print(item[0],item[1])
